
fo = open('xiaofei.csv', 'r')
lines = []
titles = {}
cities = {}
for line in fo:
    line = line.replace("\n", "")
    lines.append(line.split(","))
for i in range(len(lines)):
    if i == 0:
        titleLine = lines[i]
        for j in range(len(titleLine)):
            titles[titleLine[j]] = j
    cities[lines[i][0]] = i
fo.close()

inp = input('请输入你要查询的城市和项目（以空格分隔）：')
inps = inp.split(' ')
infos = []

columnNo = 0
for k in range(len(inps)):
    if k == 0:
        columnNo = cities.get(inps[k])
        infos.append(inps[k])
    else:
        infos.append(lines[columnNo][titles.get(inps[k])])

for i in range(len(infos)):
    if i == 0:
        print("你输入的城市为：{}".format(infos[i]))
    else:
        print("{0}的消费金额为：{1}".format(inps[i], infos[i]))
